<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    /*
    * 1. 字面量方式创建
    * 2. 使用构造函数
    * */

    /*
    * 构造函数
    * */

    function Dog(name, color, brand, weight) {
        /*定义属性*/
        this.name = name;
        this.color = color;
        this.brand = brand;
        this.weight = weight;

        /*定义方法*/
        this.chaijia = function () {
            console.log('my name is ' + this.name, ' 我能拆家');
        }
        this.houjiao = function () {
            console.log('my name is ' + this.name, ' 我能吼叫');
        }
    }

    // 使用 new 关键字得到对象，一般称之为 实例化
    var xiaohuang = new Dog('小黄', 'gold', '金毛', '70kg');
    console.log(xiaohuang.name);
    console.log(xiaohuang.color);
    xiaohuang.chaijia();
    xiaohuang.houjiao();

</script>

</html>
